/** 
 * 用户信息接口
 */
//请求方法
function my_infomation() {
	interfRequest.user_info.data = {
		refresh: "1"
	}
	socialRequest(interfRequest.user_info)
}

//成功函数回调
function user_infoHandle(data) { 
	var head_img_url = data.data.head_img_url;
	if(!head_img_url){
		$('#my_heard').attr('src', '../../images/log.png');//默认头像
	}else{
		$('#my_heard').attr('src', 'https://ypao.oss-cn-shenzhen.aliyuncs.com/' + data.data.head_img_url)
	} 
	$('.mylisy_name').text(data.data.nickname); //昵称
	$('.mylist_bottom').text(data.data.personality_signature); //个性签名
	$('#follow_number').text(data.data.follow); //关注
	$('#fans_number').text(data.data.fans); //粉丝
	$('#marked_number').text(data.data.marked); //被标记
}

/** 
 * 荣誉值接口
 */
//请求方法
function _honor_value() {
	var user_id = localStorage.getItem("user_id");
	interfRequest._honor_value.data = {
		user_id: user_id
	}
	socialRequest(interfRequest._honor_value)
}

//成功函数回调
function _honor_valueHandle(data) { 
	var value_number = Number(data.data)
	$('#honor_value_number').text(value_number.toFixed(4)); //个性签名
}

//页面进入执行方法
window.onload = function() {
	mui.plusReady(function() {
		var self = plus.webview.currentWebview();
		my_infomation();
		_honor_value(); //荣誉值
		//刷新界面
		window.addEventListener('refresh', function(e) { //执行刷新
			location.reload();
		});

	});
}

//个人信息  
mui('body').on('tap', '#user_setting', function() {
	window.top.location.href = "../my/personal_information.html"
});

//设置 
mui('body').on('tap', '.my_icon_size', function() {
	mui.openWindow({
		url: 'account_settings.html',
		id: 'account_settings',
		createNew: true
	});
});

//关注
mui('body').on('tap', '#attention_btn', function() {
	window.top.location.href = "../my/my_follow.html"
});

//粉丝
mui('body').on('tap', '#fans_btn', function() {
	window.top.location.href = "../my/fans.html"
});

//荣誉值
mui('body').on('tap', '#honor_btn', function() {
	window.top.location.href = "../my/honor_record.html"
});

//我的动态
mui('body').on('tap', '#my_dynamic', function() {
	window.top.location.href = "../my/my_dynamic.html"
});

//我的标记
mui('body').on('tap', '#my_sign', function() {
	window.top.location.href = "../my/my_sign.html"
});

//帮助中心
/*mui('body').on('tap', '#help_btn', function() {
	window.top.location.href = "../my/help_center.html"
});*/

//草稿箱
mui('body').on('tap', '#drafts_btn', function() {
	window.top.location.href = "../my/drafts.html"
});

//底部菜单
mui('body').on('tap', '.mui-tab-item', function() {
	window.top.location.href = this.href;
	$(this).addClass("mui-active");
});

//消息
mui('body').on('tap', '#my_news', function() {
	window.top.location.href = "../news/fx_message.html";
});

//我的
mui('body').on('tap', '#user', function() {
	window.top.location.href = "my.html";
});

//发布动态
mui('body').on('tap', '.public_menu_img a', function() {
	var sta = $(this).attr("sta");
	var mag = $("#mag").val(); //提示  
	if(mag == "请先登录") { //判断是否登录 
		var btnArray = ['否', '是'];
		mui.confirm(mag, '提示', btnArray, function(e) {
			if(e.index == 1) {
				mui.openWindow({
					url: '../user/login.html',
					id: 'login',
				});
			} else {}
		})
	} else if(sta == 1) { //发布图文
		mui.openWindow({
			url: '../index/issued_by.html',
			id: 'issued_by',
		});
	} else if(sta == 2) { //发布视频
		mui.openWindow({
			url: '../index/issued_video.html',
			id: 'issued_video',
		});
	}

});

//二级按钮退出APP
var first = null;
mui.back = function() {
	//	首次按键，提示‘再按一次退出应用’
	if(!first) {
		first = new Date().getTime();
		mui.toast('再按一次退出应用');
		setTimeout(function() {
			first = null;
		}, 1000);
	} else {
		if(new Date().getTime() - first < 1000) {
			plus.runtime.quit();
		}
	}
};